<!--
 * @Author: ChenCaoYang
 * @Date: 2021-05-27 22:15:57
 * @LastEditors: YaoXiaoTian
 * @LastEditTime: 2021-06-10 14:17:36
-->
<template>
  <div class="container">
    <!-- meun -->
    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      active-text-color="#CF975A"
      @select="handleSelect"
    >
      <el-menu-item index="1">全部订单</el-menu-item>
      <el-menu-item index="2">已付款</el-menu-item>
      <el-menu-item index="3">退货</el-menu-item>
      <el-menu-item index="4">未支付</el-menu-item>
    </el-menu>
    <!-- 全部订单 -->
    <AllProducts :data="dataList" v-if="activeIndex == 1" />
    <!-- 已付款 -->
    <TobeReceived v-if="activeIndex == 2" />
    <!-- 退货 -->
    <ReturnGoods v-if="activeIndex == 3" />
    <Unpaid v-if="activeIndex == 4" />
  </div>
</template>

<script>
import TobeReceived from "./children/TobeReceived";
import AllProducts from "./children/AllProducts";
import ReturnGoods from "./children/ReturnGoods";
import Unpaid from "./children/Unpaid/index.vue";
import { get_data } from "../../utils/utils";
export default {
  name: "userCards",
  data() {
    return {
      activeIndex: "1",
      dialogVisible: false,
      api: "",
      page: 1,
      rows: 10,
      total: 0,
      dataList: [],
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          price: "100",
          number: "30",
          count: "50",
          goods: {
            img: require("@/assets/imgs/banana.jpg"),
            title: "新鲜现采沙田柚美味多汁酸甜可口农场直达",
            info: "川味香肠458gx1(自然风干)",
          },
        },
      ],
      multipleSelection: [],
      tuikuanInfo: "",
    };
  },
  components: {
    TobeReceived,
    AllProducts,
    ReturnGoods,
    Unpaid,
  },
  mounted() {
    this.activeIndex = this.$route.query.active;
    if (this.activeIndex == 1) {
      this.api = this.$apiPath.getOrder;
    } else if (this.activeIndex == 2) {
      this.api = this.$apiPath.getOrder;
    } else if (this.activeIndex == 3) {
      this.api = this.$apiPath.getReturnList;
    }
    this.getData();
  },
  methods: {
    changePage() {
      console.log(1);
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    wuliu() {
      this.$router.push({
        path: "/order/userCards/logisticsDetails",
      });
    },
    getData() {
      this.$http
        .fetch(
          `${this.api}?page=${this.page}&rows=${this.rows}&customerId=${
            JSON.parse(get_data("userInfo")).id
          }`,
          {
            method: "get",
          }
        )
        .then((res) => {
          if (res.code === 200) {
            this.dataList = res.data[0].orderList;
          }
        })
        .catch((err) => {
          return Promise.reject(err);
        });
    },
    handleSelect(key) {
      this.activeIndex = key;
      // console.log(key, keyPath);
    },
    tuihuo() {
      this.dialogVisible = true;
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  width: 1200px;
  margin: 0 auto;
  /deep/.el-table th > .cell {
    text-align: center;
  }
  /deep/.bodyer {
    text-align: center;
  }
  .goods_box {
    box-sizing: border-box;
    display: flex;
    .goods_info {
      padding: 25px 0;
      margin-left: 23px;
      p:first-child {
        font-size: 14px;
        font-family: PingFangSC;
        font-weight: 400;
        color: #666666;
        margin-bottom: 10px;
      }
      p:last-child {
        font-size: 12px;
        font-family: Source Han Sans CN;
        font-weight: 300;
        color: #999999;
      }
    }
  }
  .price,
  .count {
    font-size: 18px;
    font-weight: 500;
    color: #ff9933;
  }
  .oper {
    p:first-child {
      font-size: 14px;
      font-weight: 400;
      color: #999999;
      cursor: pointer;
    }
    .wuliu {
      font-size: 14px;
      font-weight: 400;
      color: #ff9933;
      cursor: pointer;
      margin-bottom: 8px;
    }
  }
  .isOver {
    overflow: hidden;
    padding-right: 50px;
    margin-top: 67px;
    button {
      float: right;
      width: 150px;
      padding: 17px 20px;
      background: #cf975a;
      border-radius: 28px;
    }
  }
  .el-dialog__title {
    font-size: 30px;
    font-weight: 500;
    color: #5c5f68;
    margin-top: 10px;
  }
  .content {
    .title {
      font-size: 18px;
      font-weight: 400;
      color: #333333;
    }
    .product_info {
      display: flex;
      margin-top: 20px;
      align-items: center;
      margin-bottom: 20px;
      .img {
        width: 100px;
        height: 100px;
        margin-right: 24px;
        img {
          width: 100%;
          height: 100%;
          border-radius: 5px;
        }
      }
      .product_name {
        height: 49px;
        width: 406px;
        .title {
          margin-bottom: 10px;
          font-size: 14px;
          font-weight: 600;
          color: #666666;
          width: 100%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .product_name {
          font-size: 12px;
          font-weight: 300;
          color: #9999;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .test {
      margin-top: 20px;
      margin-bottom: 30px;
    }
    .money {
      span:last-child {
        float: right;
        font-size: 18px;
        font-weight: 400;
        color: #ff9933;
      }
    }
    .submit {
      padding-right: 0;
      display: flex;
      justify-content: center;
    }
  }
  /deep/.footer {
    padding: 0;
    margin: 0 auto;
    margin-top: 30px;
    margin-bottom: 33px;
    background-color: #ffffff;
    .btn-prev {
      width: 74px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
    }
    .btn-next {
      width: 74px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
      color: #999999;
    }
    .el-pager li {
      width: 30px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
      color: #999999;
    }
    .el-pager {
      .number {
        text-align: center;
        padding: 0;
      }
      //   .number:hover {
      //     color: #999999 !important;
      //   }
      li:not(.active).number:hover {
        color: #999999 !important;
      }
    }
    .el-pager li:not(.disabled).active {
      background-color: #cf975a;
    }
  }
}
</style>
